import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/layout'

Vue.use(VueRouter)

const routes = [
  { // 首页
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      { path: '/dashboard', component: () => import('@/views/home/dashboard') }
    ]
  },
  { // 用户管理
    path: '/user',
    component: Layout,
    redirect: '/user/list',
    children: [
      { path: '/user/list', component: () => import('@/views/user/list') } // 用户列表
    ]
  },
  { // 登录页面
    path: '/login',
    component: () => import('@/views/login'),
    name: 'login'
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
